package com.best.core.utils;

/**
 * ClassName: BeanUtils Package: com.best.core.utils Description: 对象复制 Datetime: 2020/6/11 16:23
 * Author: nike
 */
public class BeanUtils {

    /**
     * 对象复制
     * 
     * @param source 来源对象
     * @param target 目标对象
     * @param <T>
     * @return
     */
    public static <T> T copy(Object source, Class<T> target) {
        if (source == null) {
            return null;
        }
        if (target == null) {
            return null;
        }
        try {
            T t = target.newInstance();
            org.springframework.beans.BeanUtils.copyProperties(source, t);
            return t;
        } catch (Exception e) {
            return null;
        }
    }
}

